<%--
  Created by IntelliJ IDEA.
  User: root
  Date: 11/12/24
  Time: 8:06 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:if test="${pageInfo.pages > 1}">
    <nav class="navigation pagination" role="navigation">
        <div class="nav-links">
            <c:choose>
                <c:when test="${pageInfo.pages <= 3}">
                    <c:set var="begin" value="1"/>
                    <c:set var="end" value="${pageInfo.pages}"/>
                </c:when>
                <c:otherwise>
                    <c:set var="begin" value="${pageInfo.pageNum-1}"/>
                    <c:set var="end" value="${pageInfo.pageNum+2}"/>
                    <c:if test="${begin < 2}">
                        <c:set var="begin" value="1"/>
                        <c:set var="end" value="3"/>
                    </c:if>
                    <c:if test="${end > pageInfo.pages}">
                        <c:set var="begin" value="${pageInfo.pages-2}"/>
                        <c:set var="end" value="${pageInfo.pages}"/>
                    </c:if>
                </c:otherwise>
            </c:choose>
            <!--up one page -->
            <c:choose>
                <c:when test="${pageInfo.pageNum eq 1}">
                    <!-- First page, hide up one page button -->
                </c:when>
                <c:otherwise>
                    <a class="page-numbers" href="${pageUrlPrefix}=${pageInfo.pageNum-1}">
                        <span class="fa fa-angle-left"></span>
                    </a>
                </c:otherwise>
            </c:choose>

            <!-- Show first page number -->
            <c:if test="${begin >= 2}">
                <a class="page-numbers" href="${pageUrlPrefix}=1">1</a>
            </c:if>

            <!-- Show dot dot dot ...-->
            <c:if test="${begin > 2}">
                <span class="page-numbers dots">...</span>
            </c:if>

            <!-- Print Page Number -->
            <c:forEach begin="${begin}" end="${end}" var="i">
                <c:choose>
                    <c:when test="${i eq pageInfo.pageNum}">
                        <a class="page-numbers current">${i}</a>
                    </c:when>
                    <c:otherwise>
                        <a class="page-numbers" href="${pageUrlPrefix}=${i}">${i}</a>
                    </c:otherwise>
                </c:choose>
            </c:forEach>

            <!-- Show dot dot dot -->
            <c:if test="${end < pageInfo.pages-1}">
                <span class="page-numbers dots">...</span>
            </c:if>

            <!-- Show Final Page Number -->
            <c:if test="${end < pageInfo.pages}">
                <a href="${pageUrlPrefix}=${pageInfo.pages}">${pageInfo.pages}</a>
            </c:if>

            <!-- Next Page -->
            <c:choose>
                <c:when test="${pageInfo.pageNum eq pageInfo.pages}">
                    <!-- Final Pgae hidden next page button -->
                </c:when>
                <c:otherwise>
                    <a class="page-numbers" href="${pageUrlPrefix}=${pageInfo.pageNum+1}">
                        <span class="fa fa-angle-right"></span>
                    </a>
                </c:otherwise>
            </c:choose>

        </div>
    </nav>
</c:if>
<%--<html>--%>
<%--<head>--%>
<%--    <title>Title</title>--%>
<%--</head>--%>
<%--<body>--%>

<%--</body>--%>
<%--</html>--%>
